﻿using System;
using System.Collections.Generic;
using System.Text;
using Mighty.Common;

namespace Mighty.Brain
{
    public class TMBrainAllPass : BasicBrain
    {
        public override HandedCard RoundTicEvent()
        {
            Dictionary<int, int> winrate = new Dictionary<int, int>();

            int j = 0;
            foreach (HandedCard card in gameInfo.myCards)
            {
                winrate.Add(j,WinRateCalc(card));
                j++;

            }

            int throwCard = 0;
            int maxRate = -1;

            for (int i = 0; i < 10; i++)
            {
                if (winrate[i] > maxRate)
                {
                    throwCard = i;
                    maxRate = winrate[i];
                }
            }

            return gameInfo.myCards[throwCard];
        }

        private int WinRateCalc(HandedCard card)
        {
            if (card.isPossible == false)
                return -1;

            int winrate = 0;
            //gameInfo.betting.giruda;
            if ((int)card.shape == (int)gameInfo.betting.giruda)
                winrate += 10;
            if (card.number == 14)
                winrate += 9;
            if (card.number == 13)
                winrate += 7;
            if (card.number == 12)
                winrate += 4;
            if (card.number == 11)
                winrate += 2;
            if (card.number == 10)
                winrate += 1;

            return winrate;
        }

        public override Betting BettingTicEvent()
        {
            Betting betting = new Betting();

            betting.isPass = true;
            
            return betting;
        }
    }
}
